package com.qi.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import com.qi.pojo.dto.LoginBody;
import com.qi.pojo.vo.AjaxResult;
import com.qi.services.IUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/auth")
@Tag(name = "后台认证管理")
public class AdminAuthController {

    @Resource
    private IUserService userService;

    @SaIgnore
    @Operation(summary = "登录")
    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginBody loginBody) {
        userService.adminLogin(loginBody);
        SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
        return AjaxResult.success("登录成功", tokenInfo);
    }
}
